<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<button id="btn">发送请求</button>


<h1>表单提交</h1>
<form action="/user/set2" method="post">
        <input type="text" name="username" value="zhangsan">
        <hr>
        <input type="text" name="birthday" value="2000/10/10"> <!--date控件默认提交为--->
        <hr>
        <input type="submit">
</form>



<script>

        $("#btn").click(function () {

                // ajax提交默认为 -  改成/的话就会报400错误,用jsonformat
                // 表单提交默认为 / 用datetimeformat
                var user = {id: 1, username: "zhangsan", birthday: "2000-10-10"};//这里是string转date用到jsonformat


                $.ajax({
                        url: "/user/set",
                        type:"post",
                        contentType: "application/json",
                        data: JSON.stringify(user),
                        success: function (res) {
                                console.log(res)
                        }
                })

        })
</script>